<%--
  Created by IntelliJ IDEA.
  User: 18358
  Date: 2022/4/15
  Time: 17:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <meta charset="utf-8">
    <title>列表</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css">
</head>
<body>
<div style="width: 100%;font-size: 50px;text-align: center">太难改样式了遭不住了</div>
<!-- Table goes in the document BODY -->
<table class="hovertable" style="width: 80%;height: 100%;">
    <tr style="height: 50px">
        <td colspan="11"><a href="${pageContext.request.contextPath}/purchase/toAdd/0" style="font-size: 30px">进货</a></td>
    </tr>
    <tr>
        <th>进货时间</th>
        <th>进货商品编号</th>
        <th>进货商品名</th>
        <th>商品总数</th>
        <th>进货数量</th>
        <th>进货单价</th>
        <th>商品供应商</th>
        <th>采购业务人</th>
        <th colspan="3">操作</th>
    </tr>
    <c:forEach items="${purchase}" var="p">
        <tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';"
            style="background-color: rgb(212, 227, 229);">
            <td><fmt:formatDate pattern="yyyy-MM-dd" value="${p.purchaseTime}"/></td>
            <td>${p.goodsId}</td>
            <td>${p.goods.goodsName}</td>
            <td>${p.goods.goodsNum}</td>
            <td>${p.amount}</td>
            <td>${p.price}</td>
            <td>${p.supplier.supplierName}</td>
            <td>${p.user.name}</td>
            <td><a href="#">详情</a></td>
            <td><a href="${pageContext.request.contextPath}/purchase/toAdd/${p.id}">修改</a></td>
            <td>
                <a class="a" id="${p.id}" href="#">删除</a>
            </td>
        </tr>
    </c:forEach>

</table>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/layer/layer.js"></script>
<script type="text/javascript">
    $(() => {
        $(".a").click(function (e) {
            let a = $(this).attr("id")
            layer.confirm('确定删除吗', {
                btn: ['确定', '取消'] //可以无限个按钮
                , yes: function (index, layero) {
                    $(window).attr('location',"${pageContext.request.contextPath}/purchase/delete/"+a);
                }
            }, function (index, layero) {

            })
        })
    })
</script>
</body>
</html>
